function checkToken() {
    return async function (ctx, next) {
        const {token} = ctx.request.header
        if (token) {
            try {
                const result = ctx.app.jwt.verify(token, ctx.app.config.jwt.sercet)
                if (result.end_time >= Date.now() / 1000) {
                   await next()
                } else {
                    ctx.body = {
                        code: 4004,
                        msg: "token失效",
                    };
                }
            } catch (err) {
                ctx.body = {
                    code: 4005,
                    msg: "非法访问",
                };
            }

        } else {
            ctx.body = {
                code: 0,
                msg: "token不存在",
            };
        }

    }

}
module.exports = checkToken